package com.sren.initializrstart.controller;

import com.sren.initializrstart.service.WeatherDataService;
import com.sren.initializrstart.vo.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sren
 * @create 2018-12-06 下午2:49
 **/

@RestController
@RequestMapping("/weather")
public class HelloController {

    @Autowired
    private WeatherDataService weatherDataService;

    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

    @GetMapping("/cityId/{cityId}")
    public WeatherResponse getWeatherByCityId(@PathVariable String cityId) {
        return weatherDataService.getDataByCityId(cityId);
    }

    @GetMapping("/cityName/{cityName}")
    public WeatherResponse getWeatherByCityName(@PathVariable String cityName) {
        return weatherDataService.getDataByCityName(cityName);
    }

}
